<%@include file="/jsp/init.jspf" %>
<layout:top/>
<hunk:init autocompleter="true"/>
<h1  class="pagetitle">INVOICE</h1>
<hunk:container>
    <hunk:validator form="invoiceForm">
        <hunk:form action="invoice?action=save" name="invoiceForm">
            <table class="hundred">
                <tr>
                    <td class="border all padding4">
                        <table>
                            <tr>
                                <td><label class="heading1">Consignor</label></td>
                            </tr>
                            <tr>
                                <td><hunk:textarea name="invoice.consignor.address" container="NULL" rows="5" cols="40"/></td>
                            </tr>
                        </table>
                    </td>
                    <td class="border all padding4">
                        <table>
                            <tr>
                                <td>Invoice No</td>
                                <td><hunk:text name="invoice.invoiceNo" container="NULL"/></td>
                                <td>Export Date</td>
                                <td><hunk:calendar name="dateFormatted"  container="NULL"/></td>
                            </tr>                           
                            <tr>
                                <td>IEC CODE</td>
                                <td><hunk:text name="invoice.iecCode" container="NULL"/></td>
                            </tr>
                            <tr>
                                <td>Order no</td>
                                <td><hunk:text name="invoice.orderNo" container="NULL"/></td>
                                <td>Order Date</td>
                                <td><hunk:calendar name="orderDateFormatted"  container="NULL"/></td>
                            </tr>
                            <tr>
                                <td>Other References (CS) AD CODE : </td>
                                <td><hunk:text name="invoice.adCode" container="NULL"/></td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td class="border all padding4">
                        <table>
                            <tr>
                                <td><label class="heading1">Consignee</label></td>
                            </tr>
                            <tr>
                                <td><hunk:textarea name="invoice.consignee.address" container="NULL" rows="5" cols="40"/></td>
                            </tr>
                        </table>
                    </td>
                    <td class="border all padding4">
                        <table class="hundred">
                            <tr>
                                <td colspan="3" class="heading1 border b">Buyers (if other than consignee )</td>
                            </tr>
                            <tr>
                                <td>Country of Origin of Goods</td>
                                <td><hunk:autocompletor name="invoice.destinationCountry" id="invoice_destinationCountry"  query="COUNTRY"  container="NULL"/></td>
                            </tr>
                            <tr>
                                <td>Country of final Destination</td>
                                <td><hunk:autocompletor name="invoice.originCountry" id="invoice_originCountry" query="COUNTRY"  container="NULL"/></td>
                            </tr>
                            <tr>
                                <td>Pre - Carriage of Goods By : </td>
                                <td><hunk:text name="invoice.preBy" container="NULL"/></td>
                            </tr>
                            <tr>
                                <td>Terms of Delivery and Payment</td>
                                <td><hunk:text name="invoice.termsOfDelivery" container="NULL"/></td>
                            </tr>                     
                            <tr>
                                <td>Vessel / Freight No</td>
                                <td><hunk:text name="invoice.vesselNo" container="NULL"/></td>
                            </tr>
                            <tr>
                                <td>Port of Discharge</td>
                                <td><hunk:text name="invoice.pod" container="NULL"/></td>
                            </tr>
                            <tr>
                                <td>Place of Reciept by Precarrier</td>
                                <td><hunk:text name="invoice.por" container="NULL"/></td>
                            </tr>
                            <tr>
                                <td>Port of Loading</td>
                                <td><hunk:text name="invoice.pol" container="NULL"/></td>
                            </tr>
                            <tr>
                                <td>Final Destination</td>
                                <td><hunk:text name="invoice.destination" container="NULL"/></td>
                            </tr>
                        </table>
                    </td>
                </tr>               
            </table>
            <c:set var="grandTotal" value="0"/>
            <table class="hundred display_table space">
                <thead>
                    <tr>                      
                        <th title="Total number of packages">Package</th>
                        <th title="Package Type">Type</th>
                        <th title="Package weight">Weight</th>
                        <th title="Package size">Size</th>
                        <th>Description of Goods</th>
                        <th>HS Code</th>
                        <th>Qty(PCS)</th>
                        <th>Rate</th>
                        <th>Total</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tr>
                    <td colspan="10" align="center" class="bold padding4 space">INDIAN ARTISTIC HANDICRAFTS</td>
                </tr>
                <c:forEach items="${invoiceForm.invoice.charges}" var="charge" varStatus="status" >
                    <c:choose>
                        <c:when test="${status.count%2==0}">
                            <c:set var="class" value="odd"/>
                        </c:when>
                        <c:otherwise>
                            <c:set var="class" value="even1"/>
                        </c:otherwise>
                    </c:choose>
                    <tr class="${class}">                       
                        <td><hunk:text name="invoice.charges[${status.count-1}].packages" container="NULL" styleClass="small"/></td>
                        <td><hunk:text name="invoice.charges[${status.count-1}].packageType" container="NULL" styleClass="small"/></td>
                        <td><hunk:text name="invoice.charges[${status.count-1}].weight" container="NULL" styleClass="small"/></td>
                        <td><hunk:text name="invoice.charges[${status.count-1}].size" container="NULL" styleClass="small"/></td>
                        <td>
                            <hunk:autocompletor name="invoice.charges[${status.count-1}].goodDescription" id="invoice_charges_${status.count-1}" query="SELECT_ITEM" container="NULL"/><br>
                        </td>
                        <td><hunk:text name="invoice.charges[${status.count-1}].hsCode" container="NULL"/></td>
                        <td><hunk:text name="invoice.charges[${status.count-1}].quantity" container="NULL" styleClass="small"/></td>
                        <td><hunk:text name="invoice.charges[${status.count-1}].amount" container="NULL" styleClass="small"/></td>
                        <td>${charge.totalAmount}</td>
                        <td><a href="${path}/invoice.do?action=removeCharge&charge_id=${charge.id}" class="icon_16 delete"></a></td>
                        <c:set var="grandTotal" value="${grandTotal + charge.totalAmount}"/>
                    </tr>
                </c:forEach>
                    <tr class="border t space">
                    <td>&nbsp;</td>
                    <td colspan="2">Total Amount</td>
                    <td colspan="5">&nbsp;</td>
                    <td>${grandTotal}</td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td colspan="2">Amount in Words</td>
                    <td colspan="6" align="right" >
                        <jsp:setProperty name="numberToWordUtil" property="number" value="${grandTotal}"/>
                        ${numberToWordUtil.word}
                    </td>
                </tr>
                <tr><td colspan="6"><hunk:button onclick="window.location='${path}/invoice.do?action=addCharge'" label="Add charge" styleClass="button"/></td></tr>
            </table>
            <hunk:panel>
                <table class="hundred space">
                    <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="border t l b padding4" align="left">
                            <br/>
                            <b>Declaration :</b> <br>
                            We declare that this invoice shows the actual price of goods<br>
                            Described and at all particular are true and correct.
                            <br><br>
                        </td>
                        <td class="border t r b padding4">
                            Signature and Date
                        </td>
                    </tr>
                </table>
            </hunk:panel>
            <hunk:panel>
                <hunk:submit label="save"/>
            </hunk:panel>
        </hunk:form>
    </hunk:validator>
</hunk:container>

<layout:bottom/>
